FROM ubuntu:latest

WORKDIR /app

COPY . .

COPY ubuntu.sources.http /etc/apt/sources.list.d/ubuntu.sources

RUN apt-get update

RUN apt install -y apt-transport-https ca-certificates

RUN rm /etc/apt/sources.list.d/ubuntu.sources

COPY ubuntu.sources /etc/apt/sources.list.d/

COPY pie.phar /usr/local/bin/pie

RUN apt-get update

RUN apt install -y pkg-config \
        build-essential \
        autoconf \
        bison \
        re2c \
        libxml2-dev \
        libsqlite3-dev \
		7zip \
		coreutils \
		git \
        curl \
		mercurial \
        pkg-config \
        libssl-dev \
        zlib1g-dev \
		openssh-client \
		patch \
		subversion \
		tini \
		unzip \
		zip


RUN tar zxvf php-8.4.11.tar.gz

WORKDIR /app/php-8.4.11

# 开发环境
# RUN ./configure --enable-debug


# 生产环境
RUN ./configure --enable-fpm \
        --with-openssl \
         --with-zlib

# 
RUN make -j$(nproc)
# 
RUN make install

COPY php.ini-production /usr/local/lib/php.ini


RUN curl -sS https://getcomposer.org/installer | php

RUN mv composer.phar /usr/local/bin/composer

RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

RUN rm -rf /app/*

EXPOSE 9000

WORKDIR /app

CMD [ "php-fpm" ]